package com.example.demo.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.model.Customer;
import com.example.demo.repository.CustomerRepository;

@Controller
public class CustomerController {
	@Autowired
	private CustomerRepository repository;
	
	@RequestMapping("/customer/find")
	@ResponseBody
	@CrossOrigin
	public List<Customer> findAll() {
		return repository.findAll();
	}
	
	@RequestMapping("/customer/insert")
	public boolean insert() {
		Customer c = new Customer();
		c.firstName="GP";
		c.lastName="Z";
		repository.save(c);
		
		return true;
	}
}
